package com.wngbms.proxy;

import java.lang.reflect.Proxy;

/**
 * 需要配置虚拟机参数
 * -Dsun.misc.ProxyGenerator.saveGeneratedFiles=true
 */
public class ProxyTest {

    public static void main(String[] args) {

        HelloProxy helloProxy = new HelloProxy(new HelloImpl());
        Hello hello = (Hello) Proxy.newProxyInstance(Hello.class.getClassLoader(), new Class[]{Hello.class}, helloProxy);

        System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
        System.setProperty("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");
        System.out.println(hello.echo());
    }
}
